package com.sz.biz.logistics.serialno.service.impl;

import com.sz.biz.logistics.serialno.entity.SerialNoWarnNotice;
import com.sz.biz.logistics.serialno.service.NoWarnNoticeService;
import com.sz.common.base.dao.ParamData;
import com.sz.common.base.service.AbstractService;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Function: 单号预警相关功能实现 <br>
 * Author: Johnboy <br>
 * Date: 2017-12-07 17:12:00
 *
 * @author Johnboy
 */
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class NoWarnNoticeServiceImpl extends AbstractService implements NoWarnNoticeService {
    @Autowired
    SqlSessionTemplate sqlSessionTemplate;

    @Override
    public void save(SerialNoWarnNotice serialNoWarnNotice) {
        dao.save(getSqlName("insertSelective") , serialNoWarnNotice);
    }

    @Override
    public SerialNoWarnNotice queryByBatchNo(String batchNo , int ruleId, int type) {
        sqlSessionTemplate.clearCache();
        ParamData paramData = new ParamData();
        paramData.put("ruleId" , ruleId);
        paramData.put("batchNumber" , batchNo);
        paramData.put("type",type);
        SerialNoWarnNotice serialNoWarnNotice = (SerialNoWarnNotice) dao.findForObject(getSqlName("queryByBatchNoAndRule") , paramData);
        return serialNoWarnNotice;
    }

    @Override
    protected String getMapperNamespace() {
        return "SerialNoWarnNoticeMapper";
    }
}
